package com.haofengsoft.scce.controller.mine;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.haofengsoft.scce.adapter.mine.ConsultationCollectModel;

/**
 * Created by admin on 2015/7/14.
 */
public class ConsultationCollectController {
	private static ConsultationCollectController instance = null;
	private Context appContext;

	public static synchronized ConsultationCollectController getInstance(Context context) {
		if (instance == null) {
			instance = new ConsultationCollectController(context);
		}
		return instance;
	}

	public ConsultationCollectController(Context appContext) {
		this.appContext = appContext;
	}

	// 处理要闻
	public List<ConsultationCollectModel> gainConsultationCollectModelList(String json) {
		List<ConsultationCollectModel> consultationCollectModels = new ArrayList<ConsultationCollectModel>();
		try {
			JSONArray newsModelArray = JSON.parseObject(json).getJSONArray("NewList");
			for (int i = 0; i < newsModelArray.size(); i++) {
				JSONObject newsModelObj = newsModelArray.getJSONObject(i);
				ConsultationCollectModel consultationCollectModel = new ConsultationCollectModel();
				consultationCollectModel.setId(newsModelObj.getString("ID"));
				consultationCollectModel.setTitle(newsModelObj.getString("Title"));
				consultationCollectModel.setSource(newsModelObj.getString("Soure"));
				consultationCollectModel.setTime(newsModelObj.getString("StrCreateDate"));
				consultationCollectModels.add(consultationCollectModel);
			}
		} catch (Exception e) {
		}
		return consultationCollectModels;
	}
}
